All Questions
29 questions
3votes
1answer
97views
Swift Arrays: Write a rotate-right function
Task: Write a function which rotates all elements of a given array to the right. Example: [1, 2, 3] => [3, 1, 2] My solution: ...
3votes
2answers
375views
Write a Swift-function, which computes the Digital Root
Task: Write a function, which computes the Digital Root of a given number n. Here's the solution, which I developed: ...
4votes
1answer
697views
Caesar Cipher in Swift (iOS-app)
I have implemented the Caesar Cipher in Swift and incorporated it into an iOS-app. I guess it's formally correct. Please see the attached images, which show how the usage of the app is meant. Here's ...
4votes
3answers
206views
Bubble Sort as extension to Swift-Arrays
Task description: Implement an extension for Array, which sorts the elements using the Bubble Sort-algorithm. My implementation: ...
2votes
1answer
196views
Swift-function for finding missing Integers in an array of sequential Integers
Task description: Implement a function, which receives an array of unsorted numbers from 1 to 100. In the array zero or more numbers might be missing. The function shall return an array containing the ...
1vote
1answer
156views
Implement the Swift pow(base, exp)-function yourself
Task: Implement a function, which accepts two integers and results the first number raised to the power of the second number. Both numbers have to be positive. Examples: The arguments 4 and 3 shall ...
2votes
1answer
207views
Trie data structure in Swift lang
This is an implementation of a generic Trie DS, in Swift-lang, that is using however, for the sake of a easy example, strings. It implements two operations, insert and search. So it can insert a text, ...
2votes
2answers
205views
Create a custom split method that keeps the delimiters in Swift
I have implemented a custom split method that replicates the original functionality of the collection's split method in Swift and keep the delimiters (element separator). After a lot of trial and ...
2votes
1answer
125views
Projecteuler.net Problem 2 using collection pipeline Pattern
I solve projecteuler.net Problem 2 deferent way Generate number from 1 to range ex 100 and get the even number Get Fibonacci numbers from list Reduce array I have one problem with a large set of ...
2votes
1answer
258views
Trie implementation for strings in Swift
A trie for handling strings for an autocomplete dictionary. This passes my fairly casual tests, though it's always possible that there are broken edge cases, but I'm mainly concerned about design and ...
4votes
1answer
1kviews
Find minimum count of items where sum of them is X from an array
I recently faced an interview question where you have to find minimum needed items from an array that can added together to generate X value. For example giving: <...
2votes
1answer
3kviews
Dynamic Array Problem (Hacker rank)
I am trying to solve the Dynamic Array problem on HackerRank: Create a list, seqList, of N empty sequences, where each sequence is indexed from 0 to N-1. The elements within each of the N ...
2votes
1answer
182views
Sequence for Pre-order traversal of Binary Trees
I wanted to make a Sequence that can do a pre-order traversal of Binary Tree. Doing so provides automatically unlocks wonderfully useful methods, like ...
4votes
1answer
161views
Swift Prim's algorithm
Lots of Prim's algorithm implementations seem long, and rely on a priority queue implementation. If I use an adjacency matrix I can then calculate the next item to take using functional programming ...
6votes
1answer
735views
Dijkstra algorithm implementation in Swift
I've implemented Dijkstra's algorithm to find the minimum path between two nodes. ...